BIN=main
SRC=main.cpp
CC=g++
# CGI=./cgi/test_cgi
CURR=$(shell pwd)
FLAGS=-std=c++11 -lpthread

.PHONY:ALL
ALL:$(BIN) CGI       #$(CGI)

$(BIN):$(SRC)
	$(CC) -o $@ $^ $(FLAGS)
	
# $(CGI):$(CURR)/cgi/test_cgi.cc 
# 	$(CC) -o $@ $^
# .PHONY:CGI
CGI:
	cd $(CURR)/cgi;\
	make;\
	cd -

.PHONY:clean
clean:
	rm -rf $(BIN)
	rm -rf output
	cd $(CURR)/cgi;\
	make clean;\
	cd -

.PHONY:output
output:
	mkdir -p output
	cp $(BIN) output
	cp -rf wwwroot output
	cp ./cgi/test_cgi output/wwwroot
	cp ./cgi/python_cgi.py output/wwwroot
	cp ./cgi/shell_cgi.sh output/wwwroot
	cp ./cgi/mysql_cgi output/wwwroot
